package com.example.wechat.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.domain.PageRequest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.project.entity.User;
import com.example.wechat.model.WechatMessage;

/**
 * 微信聊天消息Mapper接口
 * 
 * @author ruoyi
 * @date 2025-11-12
 */
@Mapper
public interface WechatMessageMapper {

	@Select("SELECT * FROM t_wechat_message WHERE conversation_id = ${conversationId} "
			+ "AND del_flag = 0 ORDER BY send_time DESC #if(size != 0){ LIMIT ${size} }")
	public List<WechatMessage> queryByConversationId(Long conversationId, int size);

	@Select("SELECT * FROM t_wechat_message WHERE conversation_id = #{conversationId} "
			+ "AND del_flag = 0 ORDER BY send_time DESC ${user.params.dataScope}")
	public List<WechatMessage> findByConversationIdOrderBySentAtDesc(@Param("conversationId") String conversationId,
			Page<User> page);
}
